import os, sys
try:
  import docx
except:
  os.system("pip3 install --user python-docx")
  import docx

def m1_adb(a, a2_i=0):
  os.system("adb shell mkdir /storage/emulated/0/%s" %a)

  i = int(a2_i)
  os.system("adb shell screencap -p \"/storage/emulated/0/%s/%s.png\"" %(a,i))
  s2_size=int(os.popen("adb shell ls -l \"/storage/emulated/0/%s/%s.png\"" %(a,i)).read().split(" ")[4])
  os.system("adb shell input tap 450 650")
  while True:
    i +=1
    os.system("adb shell screencap -p \"/storage/emulated/0/%s/%s.png\"" %(a,i))
    os.system("adb shell input tap 450 650")
    s3_last_size=s2_size
    s2_size=int(os.popen("adb shell ls -l \"/storage/emulated/0/%s/%s.png\"" %(a,i)).read().split(" ")[4])

    if os.path.getsize("/storage/emulated/0/%s/%s.png" %(a,i)) == os.path.getsize("/storage/emulated/0/%s/%s.png" %(a,i-1)) :
      s= input("到末尾了吗？按下回车键继续截屏，输入任意字符回车以停止截屏")
      if s=="":
        continue
      else:
        break

if __name__ == "__main__":
  if len(sys.argv[1:]) ==0:
    print("请指定存放截屏的目录")
    sys.exit()
  s= sys.argv[1]
  s= s.strip('\'\"\\').rstrip('/')
  m1_adb(a=s)
